﻿@{
    Layout = null;
}

<html class="x-admin-sm">
<head>
    <meta name="viewport" content="width=device-width" />
    <meta charset="UTF-8">
    <title>仓库选择</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/Content/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/Content/X-admin/lib/layui/layui.js"></script>
    <link href="~/Content/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/Content/X-admin/js/jquery.min.js"></script>
    <script src="~/Content/X-admin/js/xadmin.js"></script>
    <script src="~/Content/Scripts/System/systemFrame.js"></script>
    <script src="~/Content/Scripts/System/Common.js"></script>
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" name="qForm" id="qForm">
                            <div class="layui-inline layui-show-xs-block">

                                <input type="text" name="code" placeholder="编码" autocomplete="off" class="layui-input" id="houseCode" style="width:150px;float:left">
                                <input type="text" name="name" placeholder="名称"  class="layui-input" id="houseName" style="width: 180px; float: left;margin-left:6px;margin-right:6px;">
                                <button class="layui-btn" lay-filter="sreach" id="btnQuery" type="button" onclick="loadData()"><i class="layui-icon">&#xe615;</i></button>
                                <button class="layui-btn" lay-filter="sreach" id="btnSure" type="button" onclick="sureChoose()"><i class="layui-icon">&#xe679;</i>确认</button>
                            </div>


                        </form>
                    </div>

                    <div class="layui-card-body layui-table-body layui-table-main">
                        <table class="layui-hide" id="list" lay-filter="list"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
    var single = "1", type = "", wareCode = undefined;
    var cData = new Array();
    $(function () {
        single = getUrlVariable("isSingle");
        type = getUrlVariable("type");
        if (type == "selps")
            wareCode = getUrlVariable("wareCode");
        loadData();
    });
    /**
    加载数据
    **/
    function loadData() {
        var condition = JSON.stringify(FormToJson("qForm"));
        var dUrl = '../Basis/GetDataList?&dataType=' + type + '&condition=' + condition  //数据接口
        if (type == "selps")//货位
            dUrl = '../Basis/GetDataList?&dataType=' + type + '&condition=' + condition + "&typesCode=" + wareCode  //数据接口

        layui.use('table', function () {
            var table = layui.table;
            table.render({
             elem: '#list'
            , url: dUrl
            , skin: 'row' //表格风格
            , even: true
            , page: false //是否显示分页
            , height: $(document).height() - $('#list').offset().top - 20
            , cols: [[ //标题栏
               { type: 'checkbox' }
             , { field: 'code', title: '编码', width: 120 }
                , { field: 'name', title: '名称', width: 150 } //空列

            ]]

            });
            //监听工具条
            table.on('checkbox(list)', function (obj) {
                var data = obj.data;
                var checkStatus = table.checkStatus('list');
                var select = new Array();
                for (var i = 0; i < checkStatus.data.length; i++) {
                    select.push(checkStatus.data[i]);
                }
                cData = select;
            });

        });
    }
    //确认选择
    function sureChoose() {
        if (cData.length < 1) {
            layer.msg("您没有选择任何数据"); return;
        } else {
            if (single == "1" && cData.length > 1) {
                layer.msg("请选择一条数据"); return;
            } else {
                if (type =="selwh")
                    parent.getWareHousePar(cData); //这是父页面函数 
                else if (type == "selps")
                    parent.getPostionPar(cData); //这是父页面函数
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            }
        }

    }
</script>
